package offer;

import java.util.ArrayList;
import java.util.List;

public class Ex57 {
    public int[][] findContinuousSequence(int target) {
        List<int[]> res = new ArrayList<>();
        int num = 0;
        int j = 1;
        for(int i = 1;i<target/2+1;i++){
            num +=i;
            while(j<i&&num>target){
                num-=j;
                j++;
            }
            if(j<i&&num==target){
                int [] list = new int[i-j+1];
                for(int k = j,d = 0;k<=i;k++,d++){
                    list[d] = k;
                }
                res.add(list);
            }
        }
        int[][] fin = new int[res.size()][];
        for (int i = 0; i < fin.length; i++) {
            fin[i] = res.get(i);
        }
        return fin;
    }

    public static void main(String[] args) {
        Ex57 ex57 = new Ex57();
        int[][] continuousSequence = ex57.findContinuousSequence(9);

    }
}
